/*
 * Copyright (c) 2019 Wormpex.com. All Rights Reserved.
 */

package com.sk.agent;

import com.sk.agent.javaag.TimeStatClassAdapter;
import jdk.internal.org.objectweb.asm.ClassReader;
import jdk.internal.org.objectweb.asm.ClassWriter;

import java.io.File;
import java.io.FileOutputStream;

/**
 * @author ke.su date: 2019-11-12 Time: 下午3:20
 */
public class TimeStatWeaveGenerator {
    public static void main(String[] args) throws Exception {
        String className = Account.class.getName();

        ClassReader cr = new ClassReader(className);

        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);

        TimeStatClassAdapter classAdapter = new TimeStatClassAdapter(cw);

        cr.accept(classAdapter, ClassReader.SKIP_DEBUG);

        byte[] data = cw.toByteArray();

        File file = new File("/Users/suke/Desktop/production/anent/com/sk/agent/Account.class");

        FileOutputStream fout = new FileOutputStream(file);
        fout.write(data);
        fout.close();

    }
}
